/**
 *Copyright(c) HNA SYSTEMS Co., LTD
 *
 *@date 2013-7-18
 * 	
 *Original Author: 郑兴(zhengxing)
 *
 *ChangeLog
 *
 */
package com.hnas.sys.orm;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

import com.hnas.core.util.StringUtil;
import com.hnas.sys.domain.PackageStatus;

/**
 * @author 郑兴(zhengxing)
 *
 */
@Entity
@Table(name="sys_package")
public class MenuPackage {
    @Id @GeneratedValue(strategy=IDENTITY)    
    @Column(name="id", nullable=false)
	private long id;
 	@Column(name="name")   
	private String name;
	private String description;
	private int priority;
	@Column(name="status", length=4)
	private String statusStr;
	@Transient
	private PackageStatus status;
	
	/**
	 * @return the id
	 */
//	@Id
//	@GeneratedValue
	public long getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	/**
	 * @return the priority
	 */
	public int getPriority() {
		return priority;
	}
	/**
	 * @param priority the priority to set
	 */
	public void setPriority(int priority) {
		this.priority = priority;
	}
	/**
	 * @return the statusStr
	 */
	
	public String getStatusStr() {
		return statusStr;
	}
	/**
	 * @param statusStr the statusStr to set
	 */
	public void setStatusStr(String statusStr) {
		this.statusStr = statusStr;
		if(StringUtil.isNotEmpty(statusStr)) {
			this.status = PackageStatus.valueOfAlias(statusStr);
		} else {
			this.status = null;
		}
	}
	/**
	 * @return the status
	 */

	public PackageStatus getStatus() {
		if(!StringUtil.isEmpty(statusStr)) {
			return PackageStatus.valueOfAlias(statusStr);
		}
		return status;
	}
	/**
	 * @param status the status to set
	 */
	public void setStatus(PackageStatus status) {
		this.status = status;
		if(null != status) {
			this.statusStr = status.getAlias();
		} else {
			this.statusStr = null;
		}
	}
}
